package com.ruoyi.web.controller.mall;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.MallCategory;
import com.ruoyi.mall.service.MallCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "商品分类管理")
@RestController
@RequestMapping("/mall/category")
public class MallCategoryController extends BaseController {
    @Autowired
    private MallCategoryService mallCategoryService;

    /**
     * 查询商品分类列表
     */
    @ApiOperation("查询商品分类列表-树形结构")
    @PostMapping("/list")
    public AjaxResult list(MallCategory mallCategory) {
        List<MallCategory> categories = mallCategoryService.selectMallCategoryList(mallCategory);
        return success(mallCategoryService.buildTreeSelect(categories));
    }
}
